package com.ebs.md.api.hit;

/**
 * Revision Author:
 *  $File: //depot/MarketData/commons-md-api/MAIN/src/main/java/com/ebs/md/api/hit/BasicHit.java $
 *  $Revision: #3 $
 *  $DateTime: 2012/09/24 14:01:03 $
 *  $Change: 115157 $
 *  $Author: Aviad.Yosef $
 */

import java.util.Calendar;

import com.ebs.md.api.IProduct;
import com.ebs.md.api.OrderSide;
import com.ebs.md.api.Rate;
import com.ebs.md.api.product.PairProduct;


public class BasicHit
implements  IHitSubmit
{
	// gened via Eclipse
	private static final long serialVersionUID = 7650198590754922918L;

	protected IProduct  product;
	
	protected HitSide   side;
	protected long      amount;      // hit amount
	protected Rate      rate;
	
	protected String    id; // hit_id (hit_id)
	protected Calendar  hitTime;
	protected String    dealCode;
	protected String    traderId;
	
	protected String    region;
	
	public BasicHit(IProduct product, HitSide side, long amount, Rate rate
			, String id, Calendar hitTime, String dealCode, String traderId, String region) {
		super();
		this.product= product;
		this.amount = amount;
		this.side   = side;
		this.rate   = rate;

		this.id       = id;
		this.hitTime  = hitTime;
		this.dealCode = dealCode;
		this.traderId = traderId;
		
		this.region = region;
	}

	public IProduct getProduct() {
		return product;
	}
	public Rate getRate() {
		return rate;
	}
	public long getAmount() {
		return amount;
	}
	@Deprecated
	public OrderSide getSide() {
		return side.getMatchOrderSide();
	}
	public HitSide getHitSide() {
		return side;
	}
	public String getId() {
		return id;
	}
	public String getDealCode() {
		return dealCode;
	}
	public String getTraderId() {
		return traderId;
	}
	public Calendar getTime() {
		return hitTime;
	}

	public long getTimestamp() {
		return hitTime.getTimeInMillis();
	}
	// getPair - for convenience 
	public PairProduct getPair() {
		return (PairProduct)product;
	}
	public String getRegion() { 
		return region;
	}
	
	
	// gened with Eclipse on "hitId"
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	// gened with Eclipse on "hitId"
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BasicHit other = (BasicHit) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		
		sb.append(  "id=");
		sb.append(   id);
		sb.append(", product=");
		sb.append(   product);
		sb.append(", side=");
		sb.append(   side);
		sb.append(", amount=");
		sb.append(   amount);
		sb.append(", rate=");
		sb.append(   rate);
		sb.append(", hitTime=");
		sb.append(   hitTime.getTime());
		
		return sb.toString();
	}

}
